import {httpPost} from "@/common/http";
import md5 from 'js-md5';
import store from "@/store"

const prefix = "/auth";
const registerUri = prefix + "/register";
const loginUri = prefix + "/login";
const logoutUri = prefix + "/logout";
const initUri = prefix + "/init";

const register = (data) => {
    return httpPost(registerUri, data)
};

const login = (username, password) => {
    return httpPost(loginUri, {
        username: username,
        password: md5(password),
        deviceNumber: store.state.user.vuex_device_number
    })
};

//初始化接口
const init = () => {
    return httpPost(initUri);
};

const logout = () => {
    return httpPost(logoutUri);
};


export default {
    register, login, logout, init
}
